package com.ymttest.database.sqlwapper.sqrefund;

import java.util.HashMap;
import java.util.List;

import com.ymt.database.SqlManager;
import com.ymttest.database.model.sqrefund.RefundBill;

public class RefundBillWrapper {
	
	SqlManager manager;

	public RefundBillWrapper() {
		manager = new SqlManager("sqrefund");
	}

	@SuppressWarnings("unchecked")
	public RefundBill selectByPrimaryKey(String refundNo) {

		RefundBill refundBill = null;
		List<RefundBill> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.sqrefund.RefundBillMapper.selectByPrimaryKey",
						refundNo);
		manager.commit();

		if (result.size() > 0) {
			refundBill = result.get(0);
		}

		return refundBill;
	}
	
	@SuppressWarnings("unchecked")
	public List<RefundBill> selectByOrderId(Long orderId) {

		List<RefundBill> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.sqrefund.RefundBillMapper.selectByOrderId",
						orderId);
		manager.commit();

		return result;
	}
	
	@SuppressWarnings("unchecked")
	public List<RefundBill> selectSuccessByOrderId(Long orderId) {

		List<RefundBill> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.sqrefund.RefundBillMapper.selectSuccessByOrderId",
						orderId);
		manager.commit();

		return result;
	}
	
	@SuppressWarnings("unchecked")
	public RefundBill selectByRefundNoAndOrderId(Long orderId, String refundNo) {

		HashMap<String, Object> map = new HashMap<>();
		
		map.put("order_id", orderId);
		map.put("refund_no", refundNo);
		
		RefundBill refundBill = null;
		
		List<RefundBill> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.sqrefund.RefundBillMapper.selectByRefundNoAndOrderId",
						map);
		manager.commit();
		
		if (result.size() > 0)
			refundBill = result.get(0);
		
		return refundBill;
	}
	
	public static void main(String[] args) {
		
		RefundBillWrapper test = new RefundBillWrapper();
		
//		SellerLevelHistory sellerLevelHistory = new SellerLevelHistory();
//		
//		sellerLevelHistory.setDDate(YMTDateUtil.getDate());
//		sellerLevelHistory.setSellerID(24635724);
//		sellerLevelHistory.setUpdateTime(YMTDateUtil.getDate());
//		sellerLevelHistory.setUnconfirm_amount(BigDecimal.TEN);
//		
		System.out.println(test.selectByRefundNoAndOrderId(13093258699L, "TH201206000128984"));
	}
}
